define([
    'zepto',
    'underscore',
    'backbone',
    "text!templates/tied/bindResult.html",
    "wTools",
    "area",
    "validate"

], function ($, _, Backbone, template) {
    return Backbone.View.extend({
        $el: $main,
        el: $main0,
        template: _.template(template),
        events: {
            "tap #btn": "btn"
        },
        initialize: function () {
            $("#head_back").hide();

            var postData = {
                "token": wData.urlData.token
            }, that = this;

            wAjaxForm("getTokenInfo", "", postData, function (result) {
                if (result.success) {
                    if(wData.returnUrl==''||wData.returnUrl==undefined||wData.returnUrl==null){
                        $('#btn').remove();
                    }
                    that.render(wData);
                }else{
                    wTips("请重试");
                }
            });
        },
        back: function () {
            history.back();
        },
        render: function (data) {
            var html = this.template(data);
            this.$el.html(html);
        },
        btn: function () {
            location.href = wData.returnUrl+'?'+'status='+wData.status+'&'+'trxId='+wData.trxId+'&'+'merUserId='+wData.userNo+'&'+'cardName='+wData.cardName+'&'+'cardBegin='+wData.bankCode.substring(0,6)+'&'+'cardEnd='+wData.bankCode.substring(wData.bankCode.length-4);
        },

        destroy: function () {
            this.undelegateEvents();
            this.$el.html("");
            delete this;
        }
    });
});